package com.lwq.imserver.controller;

import com.lwq.imserver.util.WebSocketUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Description:
 * Author: LiuWenQing
 * Datetime: 2022/1/18 8:42
 */
@RestController
public class SocketController {

    @GetMapping("online")
    public Object online() {
        List<String> reList = new ArrayList<>();
        for (String key : WebSocketUtil.getChannelMap()
                .keySet()) {
            reList.add(WebSocketUtil.userList.stream().filter(e->e.getId().equals(key)).findAny().get().getUserName());
        }
        return reList;
    }
}
